package com.kdzy.lshy.common.utils;

import sun.misc.BASE64Encoder;
import java.io.File;
import java.io.FileInputStream;


public class Base64Tool {

    public static String encryptToBase64(String filePath) {

        File file = new File(filePath);
        FileInputStream inputFile = null;

        try {
            inputFile = new FileInputStream(file);
            byte[] buffer = new byte[(int) file.length()];
            inputFile.read(buffer);
            inputFile.close();
            return new BASE64Encoder().encode(buffer);
        } catch (Exception e) {
            e.printStackTrace();
            return "fail";
        }

    }
}
